//
//  NSSearchDescriptor.m
//  CloudDoctor
//
//  Created by weida on 15/4/18.
//  Copyright (c) 2015年 ZhongKeYun. All rights reserved.
//

#import "NSSearchDescriptor.h"

@interface NSSearchDescriptor ()

@property(nonatomic,copy)NSString *keyPath;
@property(nonatomic,copy)NSString *key;

@end

@implementation NSSearchDescriptor

-(instancetype)init
{
    if (self = [super init])
    {
        self.asWholeSearch = YES;
        self.AutoTransfromChineseToPinyin = NO;
        self.caseSensitivity = YES;
        self.ignoreSpaceCharacter = NO;
        self.regularExpressionSearch = NO;
    }
    return self;
}

- (instancetype)initWithKeyPath:(NSString *)keyPath Key:(NSString*)key
{
    if ([self init])
    {
        self.keyPath = keyPath;
        self.key = key;
    }
    
    return self;
}


/**
 *  @brief  实例化一个搜索描述
 *
 *  @param keyPath 需要被搜索的字段路径
 *  @param key     搜索关键字
 *
 *  @return 搜索描述实例
 */
+(instancetype)searchDescriptorWithKeyPath:(NSString *)keyPath Key:(NSString *)key
{
    NSSearchDescriptor *Descriptor = [[NSSearchDescriptor alloc]initWithKeyPath:keyPath Key:key];    
    
    return Descriptor;
}


#pragma mark -Setter Method

-(void)setIgnoreSpaceCharacter:(BOOL)ignoreSpaceCharacter
{
    _ignoreSpaceCharacter = ignoreSpaceCharacter;

    _asWholeSearch = ignoreSpaceCharacter;
}
-(void)setAsWholeSearch:(BOOL)asWholeSearch
{
    _asWholeSearch = asWholeSearch;
    
    _ignoreSpaceCharacter = asWholeSearch;
}

@end
